package com.cmii.sjw.department.control.jsc.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cmii.sjw.department.control.jsc.mapper.CountyBasicInfoMapper;
import com.cmii.sjw.department.control.jsc.model.CountyBasicInfo;
import com.cmii.sjw.department.control.jsc.service.CountyBasicInfoService;
import com.cmii.sjw.department.control.jsc.vo.CountyBasicInfoVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;



@Slf4j
@Service("CountyBasicInfoService")
public class CountyBasicInfoServiceImpl extends ServiceImpl<CountyBasicInfoMapper, CountyBasicInfo> implements CountyBasicInfoService {
    @Autowired
    private CountyBasicInfoMapper countyBasicInfoMapper;

    @Override
    public CountyBasicInfoVO getByCountyName(String countyName) {
        CountyBasicInfo info = countyBasicInfoMapper.selectOne(
                new LambdaQueryWrapper<CountyBasicInfo>()
                        .eq(CountyBasicInfo::getCountyName, countyName)
                        .eq(CountyBasicInfo::getIsDeleted, 0)
                        .last("LIMIT 1")
        );
        if (info == null) {
            return null;
        }
        CountyBasicInfoVO vo = new CountyBasicInfoVO();
        BeanUtils.copyProperties(info, vo);
        return vo;
    }
}
